/* 
 * File:   mod_network.h
 * Author: alex
 *
 * Created on March 28, 2009, 3:49 PM
 */
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<netdb.h>
#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<sys/errno.h>
#include<errno.h>
#include<fcntl.h>
#include<string.h>

#ifndef _MOD_NETWORK_H
#define	_MOD_NETWORK_H

#ifdef	__cplusplus
extern "C" {
#endif
int create_TCP_server_socket(int port, int backlog, struct sockaddr_in *addr);
int create_TCP_client_socket(char IP[], int port,struct sockaddr_in *addr);
int connect_with_server(int *sd, struct sockaddr_in *addr);
int accept_connection(int *sd, struct sockaddr_in* addr);
int readn(int sd, void* buffer, int dim);
int writen(int sd, void* buffer, int dim);
int close_socket(int *sd);
int get_host_information(int *sd, struct sockaddr_in* addr, int *port, char IP[]);
int get_peer_information(int *sd, struct sockaddr_in* addr, int *port, char IP[]);

#ifdef	__cplusplus
}
#endif

#endif	/* _MOD_NETWORK_H */

